build: Add missing symbol visibility flags
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 18 Apr 2017 13:28:46 +0000 (14:28 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 3 May 2017 14:10:56 +0000 (15:10 +0100)
GTK symbols are not visible by default, and only the ones annotated with
_GDK_EXTERN (and wrapper macros) are exported. We need to define
_GDK_EXTERN during the configuration, depending on the platform and
compiler we use.

meson.build

index 54ce3c7afb51802148b5b07a7520b3ba0dac73ab..36b8001fa72bd0f7bf782b88b7b3f956f4479564 100644 (file)
@@ -255,6 +255,22 @@ foreach cflag: test_cflags
   endif
 endforeach
 
+# Symbol visibility
+if get_option('default_library') != 'static'
+  if host_machine.system() == 'windows'
+    cdata.set('DLL_EXPORT', true)
+    if cc.get_id() == 'msvc'
+      cdata.set('_GDK_EXTERN', '__declspec(dllexport) extern')
+    else
+      cdata.set('_GDK_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
+      common_cflags += ['-fvisibility=hidden']
+    endif
+  else
+    cdata.set('_GDK_EXTERN', '__attribute__((visibility("default"))) extern')
+    common_cflags += ['-fvisibility=hidden']
+  endif
+endif
+
 confinc = include_directories('.')
 gdkinc = include_directories('gdk')
 gtkinc = include_directories('gtk')